package cn.fql.basic.listener;

import cn.fql.system.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

//项目一启动 - 一定会创建一个ServletContext对象 - 启动类 - 监听器
// - 只要上下文对象一启动，监听器就会自动执行contextInitialized方法
@WebListener
public class PermissionScanInitListener implements ServletContextListener {

    @Autowired
    private IPermissionService permissionService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                //扫描注解加权限
                permissionService.scanPermission();
            }
        }).start();

    }
}
